package com.heima.leetcode.practice;

/**
 * @author 勾新杰
 * @version 1.0
 * @description: leetcode 83. 删除排序链表中的重复元素
 * @date 2025/5/16 10:50
 */
public class E83 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode sentinel = new ListNode();
        sentinel.next = head;
        ListNode curr = head, last = sentinel;
        while (curr != null) {
            if (curr.next == null || curr.val != curr.next.val) {
                last.next = curr;
                last = curr;
            }
            curr = curr.next;
        }
        return sentinel.next;
    }
}
